﻿
using HDSmartCommunity.BUS;
using HDSmartCommunity.Models;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.NetworkInformation;
using System.Threading.Tasks;

namespace HDSmartCommunity.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class ReportController : ControllerBase
    {
        public ReportController()
        {
        }

        /// <summary>
        /// 查询轿内乘梯
        /// </summary>
        /// <returns>success</returns>
        [HttpPost]
        [Route("QueryIncarevents")]
        public ResponseMessage QueryIncarevents(Incarevents incarevents)
        {
            ResponseMessage message = new ResponseMessage();
            try
            {
                ReportBUS bus = new ReportBUS();
                List<Incarevents> list = bus.QuerytIncarevents(incarevents);
                message.errcode = 0;
                message.data = list;
                message.total = bus.QuerytIncareventsCount(incarevents);
            }
            catch
            {
                message.errcode = 1;
                message.errmsg = "获取轿内乘梯记录异常";
            }
            return message;
        }


        /// <summary>
        /// 查询厅外乘梯
        /// </summary>
        /// <returns>success</returns>
        [HttpPost]
        [Route("QueryOutcarevents")]
        public ResponseMessage QueryOutcarevents(Outcarevents outcarevents)
        {
            ResponseMessage message = new ResponseMessage();
            try
            {
                ReportBUS bus = new ReportBUS();
                List<Outcarevents> list = bus.QuerytOutcarevents(outcarevents);
                message.errcode = 0;
                message.data = list;
                message.total = bus.QuerytOutcareventsCount(outcarevents);
            }
            catch
            {
                message.errcode = 1;
                message.errmsg = "获取厅外乘梯记录异常";
            }
            return message;
        }

        /// <summary>
        /// 查询设备在线离线记录
        /// </summary>
        /// <returns>success</returns>
        [HttpPost]
        [Route("QueryEquipment")]
        public ResponseMessage QueryEquipment(Equipment equipment)
        {
            ResponseMessage message = new ResponseMessage();
            try
            {
                ReportBUS bus = new ReportBUS();
                List<Equipment> list = bus.QuerytEquipment(equipment);
                message.errcode = 0;
                message.data = list;
                message.total = bus.QuerytEquipmentCount(equipment);
            }
            catch
            {
                message.errcode = 1;
                message.errmsg = "获取设备在线离线记录异常";
            }
            return message;
        }

        /// <summary>
        /// 查询模式切换记录表
        /// </summary>
        /// <returns>success</returns>
        [HttpPost]
        [Route("QueryModeRecord")]
        public ResponseMessage QueryModeRecord(ModeRecord modeRecord)
        {
            ResponseMessage message = new ResponseMessage();
            try
            {
                ReportBUS bus = new ReportBUS();
                List<ModeRecord> list = bus.QueryModeRecord(modeRecord);
                message.errcode = 0;
                message.data = list;
                message.total = bus.QueryModeRecordCount(modeRecord);
            }
            catch
            {
                message.errcode = 1;
                message.errmsg = "获取设备在线离线记录异常";
            }
            return message;
        }
      
    }
}
